package cn.szabadsag.config;

import cn.szabadsag.base.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置类
 *
 * @author yangcong
 * @date 2022年03月12日 21:30
 * @since
 */
@Configuration
public class LoginInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //  注册loginInterceptor拦截器
        registry.addInterceptor(loginInterceptor)
                //  所有路径都被拦截
                .addPathPatterns("/**")
                //  添加不拦截路径
                //  排除登录、注册接口
                .excludePathPatterns("/login")
                .excludePathPatterns("/reg")
                .excludePathPatterns("/sendCode")
                //  排除验证手机号的接口
                .excludePathPatterns("/user/verifyPhone")
                .excludePathPatterns("/fastdfs/upload")
                .excludePathPatterns("/pay/notifyUrl")
                .excludePathPatterns("/pay/returnUrl");
    }
}
